<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>积分商城</title>
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta http-equiv="Cache-Control" content="no-transform">
		<meta name="format-detection" content="telephone=no">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
		<link rel="stylesheet" href="style/css/basic.css" />
		<link rel="stylesheet" href="style/css/product_list.css" />
		<script type="text/javascript" src="style/plugin/mui/js/mui.min.js"></script>
		<script type="text/javascript" src="style/js/jquery-1.8.3.min.js"></script>
		<script type="text/javascript" src="style/mockjs/dist/mock.js"></script>
		<script type="text/javascript" src="style/js/vue.min.js"></script>
		<script type="text/javascript" src="style/js/vue-resource.js"></script>
		<script type="text/javascript" src="style/js/basic.js"></script>
	</head>

	<body>
		<div id="myinter">
			<div id="header">
				<h1>积分商城</h1>
				<span class="backicon"></span>
			</div>
			<div class="body">
				<div class="my_intergral">
					<h2>我的积分：{{myMsg.score}}</h2>
				</div>
				
				<div class="list" id="refreshContainer">
					<ul>
						<li v-for="(item,index) in productList" @tap="jumpdetail(index)">
							<a href="javascript:;"> 
								<div class="list_left_img">
									<img :src="htp+item.thumb_pic">
								</div>
								<div class="list_right_text">
									<span>{{item.title}}</span>
									<span>礼品数量：{{item.stock}}{{item.unit}}</span>
									<span class="text_color">积分：{{item.price}}</span>
								</div>
							</a>
	
						</li>
					</ul>
				</div>
			</div>
		</div>
		<script>
			new Vue({
				el:"#myinter",
				data:{
					productList:"",
					myMsg:"",
					htp:"",
					ticket:"",
				    sign:""
				},
				methods:{
					jumpdetail:function(jIndex){
						openurl_can("product_details",this.productList[jIndex].good_no)
					}
				},
				mounted:function(){
					var p=1;
					var that=this;
					that.ticket=localStorage.getItem("tick")
                    that.sign=localStorage.getItem("sig")
					that.htp=domain2;
					mui.plusReady(function(){
						mui.init({
						  pullRefresh : {
						    container:"#refreshContainer",
						    down : {
						      style:'circle',
						      color:'#2BD009',
						      height:'50px',
						      range:'100px',
						      offset:'0px', 
						      contentdown:null,
						      auto: true,
						      callback :pullrefesh  	      
						    }
						  }
						}); 
						function pullrefesh(){
							that.$http.post(domain+"/score_good/getList?t="+that.ticket+"&sign="+that.sign,{
							      	page:p++,
							      	page_size:1,
							      	can_exchange:1
							      },{emulateJSON:true}).then(
						            function (res) {
						                // 处理成功的结果
						                console.log(res.body)
						                if(res.body.code==1){
						                	if(res.body.data.length==0){
							                	mui.toast("没有更多了")
							                	return false;
							                }
						                    that.productList=res.body.data.list;
						                }else{
						                	mui.toast("暂无商品")
						                }
						            },function (res) {
						            // 处理失败的结果
						            console.log(res) 
						            }
						        ).then(function(){
						        	mui('#refreshContainer').pullRefresh().endPulldownToRefresh();   
						        });
							
						}
					})
					that.$http.post(domain+"/member/getInfo?t="+that.ticket+"&sign="+that.sign,{emulateJSON:true}).then(
			            function (res) {
			                // 处理成功的结果
			                console.log(res.body)
			                if(res.body.code==1){
			                  that.myMsg=res.body.data;
			                }else{
			                	mui.toast("暂无商品")
			                }
			            },function (res) {
			            // 处理失败的结果
			            console.log(res) 
			            }
			        )
				}
			})
		</script>
	</body>

</html>